﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using ZDSoft.TES.Entity.FunctionEntity;

namespace ZDSoft.TES.Entity.SystemEntity
{
    [ActiveRecord("Organization")]
    public class Organization : EntityBase<Organization>
    {
        /// <summary>
        /// 机构名称
        /// </summary>
        [Property]
        public string OrganizationName { get; set; }

        /// <summary>
        /// 机构类型
        /// </summary>
        [Property]
        public OrganizationType OrganizationType { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        [BelongsTo("ParentID", Lazy = FetchWhen.OnInvoke)]
        public Organization Parent { get; set; }

        [HasMany(typeof(Organization), ColumnKey = "ParentID", Inverse = true, Lazy = true)]
        public IList<Organization> Children { get; set; }

        [HasAndBelongsToMany(typeof(Course), Table = "CourseOrganization", ColumnKey = "OrganizationID", ColumnRef = "CourseID", Inverse = true, Lazy = true)]
        public IList<Course> Courses { get; set; }

        //[HasAndBelongsToMany(typeof(Evaluate), Table = "EvaluateOrganization", ColumnKey = "OrganizationID", ColumnRef = "EvaluateID", Inverse = true, Lazy = true)]
        [HasMany(typeof(Evaluate), ColumnKey = "OrganizationID", Inverse = true, Lazy = true)]
        public IList<Evaluate> Evaluates { get; set; }

        [HasMany(typeof(User), ColumnKey = "OrganizationID", Inverse = true, Lazy = true)]
        public IList<User> Users { get; set; }
    }
}
